<template>
  <a-modal
    v-model:visible="dialogVisible"
    width="80%"
    :title="title"
    destroyOnClose
    :maskClosable="false"
    @cancel="close"
  >
    <UpdateSystemRoleManage
      :id="id"
      ref="updateSystemRoleManageRefs"
      :user-id="userId"
      :is-dialog="true"
      :look="lookName"
      :orgin="orgin"
      @updateList="updateList"
      @loadFinish="loadFinish"
      @setLoading="setLoading"
    />
    <div slot="footer">
      <a-button @click="close">{{!orgin ? '取消': '关闭'}}</a-button>
      <a-button type="primary" @click="handleOk" :loading="(loadingData.isOpr&&loadingData.isBus) || loading"
      v-if="!orgin">确定</a-button>
    </div>
  </a-modal>
</template>

<script>
  import UpdateSystemRoleManage from "./UpdateSystemRoleManage"
export default {
  name: 'AddResource',
  computed: {
    lookName() {
      return this.look
    }
  },
  components: {
    UpdateSystemRoleManage
  },
  data() {
    return {
      loading: false,
      dialogVisible: false,
      loadingData: {
        isOpr: true,
        isBus: true
      },
    }
  },
  props: {
    userId: {
      type: String,
      default: ""
    },
    id:{
      type: String,
      default: ""
    },
    look: {
      type: String,
      default: ''
    },
    title: {
      type: String,
      default: "添加资源"
    },
    //弹窗来源
    orgin: {
      type: String,
      default: ""
    }
  },
  watch: {
    dialogVisible(newVal) {
      this.loadingData = {
        isOpr: true,
        isBus: true
      }
      // if(newVal) {
      //   this.$refs.updateSystemRoleManageRefs&&this.$refs.updateSystemRoleManageRefs.initData()
      // }
    }
  },
  methods: {
    loadFinish(loadingData) {
        this.loadingData.isOpr = loadingData.isOpr
        this.loadingData.isBus = loadingData.isBus
    },
    open() {
      this.dialogVisible = true;
    },
    close() {
      this.dialogVisible = false;
      this.$emit('close')
    },
    handleOk() {
      this.$refs.updateSystemRoleManageRefs.submit()
    },
    setLoading() {
      this.loading = true
    },
    updateList() {
      this.loading = false
      this.close()
    }
  }

}
</script>

<style lang="less" scoped>
/deep/ .ant-modal-body {
  height: calc(var(--heightVh) * 0.62);
  overflow: hidden;
}
  /deep/ .content-bx {
    overflow: visible!important;
    height: calc(var(--heightVh) * 0.62)!important;
    .ant-card {
      height: calc(100% - 44px);
      box-sizing: border-box;
      .ant-card-body {
         height: 100%;
         box-sizing: border-box;
        .content-wrapper {
          height: calc(100% - 84px);
          overflow: hidden;
          .ant-spin-nested-loading{
            height: 100%;
            .ant-spin-container {
              height: 100%;
            }
          }
        }
      }
    }
    .ant-tree {
      min-height: 50px!important;
      height: 100%!important;
      overflow: auto!important;
    }
  }
/deep/ .authManage-container {
  height: 100%;
  .ant-row, .ant-col, .scroll-treeBox, .ant-spin-container{
    height: 100%;
  }
  .s-c {
    box-sizing: border-box;
    overflow-y: auto;
  }
  .o-z {
    height: calc(100% - 50px)
  }
  .treeBox {
    height: calc(100% - 38px)
  }
  .ant-tree {
    min-height: 50px!important;
    height: calc(100% - 40px)!important;
    overflow: auto!important;
  }
}
</style>
